import React from 'react';
import style from "./index.module.less"
import {LeftOutline} from "antd-mobile-icons"
import {  useNavigate } from "react-router-dom"



const HeaderTitle = (props) => {
  // const history = useHistory();
	const navigate = useNavigate()
  const backFun = ()=>{
    // alert("点击了返回")
    // setTimeout(()=>{
		// 	if (window.scrollTo) {
		// 		window.scrollTo(0, 0);
		// 		// alert(9)
		// 	} else if (document.body.scrollTop) {
		// 		document.body.scrollTop = 0;
		// 	} else {
		// 		document.documentElement.scrollTop = 0;
		// 	}
		// },10)
    navigate(-1);
  // navigate(-1);
   // window.history.back();
  }
  return (
    <header className={style['header-title']}>
      {/* <div></div> */}
		{
			props.link ? (<LeftOutline className={style['icon']} onClick={() => navigate('/index')}/>) : (<div onClick={() => backFun()} style={{ cursor: 'pointer' }}><LeftOutline style={{cursor:'pointer'}} className={ style['icon']}  /></div>)
		}
        {props.title}
        <span  style={{ cursor: 'pointer' }} className={style['icon-right']} onClick={() => navigate('/index')}>{props.right_title}</span>
    </header>
  )
}

export default HeaderTitle